<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ include file="/common/taglibs.jsp" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>查询</title>

    <%@ include file="/common/util.jsp" %>


    <script type="text/javascript">
        //新增
        function add() {
            self.location = "${cdnctx}/system/customerinfo/customerinfoNewInit.shtml?params=add";
        }
        //查询
        function search() {
            window.location.href = "${cdnctx}/system/customerinfo/customerMain.shtml?groupcode=" + $("#groupcode").val().trim()
                    + "&companycode=" + $("#companycode").val().trim() + "&customername=" + $("#customername").val().trim();
        }

        //翻页
        function jumpPage(pageNo) {
            window.location.href = "${cdnctx}/system/customerinfo/customerMain.shtml?pageIndex=" + pageNo;
        }
        //删除单条记录
        function todelete(id, modifyStamp) {
            dialog_confirmled("确定删除吗？", function () {
                self.location = "${cdnctx}/system/customerinfo/customerinfoDelete.shtml?id=" + id;
            });
        }
        //修改单条记录
        function update(id) {
            self.location = "${cdnctx}/system/customerinfo/customerinfoNewInit.shtml?id=" + id;
        }
        function setPosition(id, customername) {
            $.dialog({
                id: 'setMap',
                title: customername + '_地图设置',
                content: '<iframe name="OpensetMap" width=900 height=550 frameborder=0 scrolling=auto src="${cdnctx}/customerMap/searchPostion.shtml?customerId=' + id + '"></iframe>',
                width: '900px',
                height: '550px',
                ok: function () {
                    $customerInfoForm = $("iframe[name='OpensetMap']").contents().find("#customerInfoForm");
                    $.ajax({
                        type: "POST",
                        contentType: "application/json",
                        url: '${cdnctx}/system/customerinfo/ajaxUpdate.shtml',
                        data: JSON.stringify($customerInfoForm.serializeObject()),
                        dataType: "json",
                        success: function (data) {
                            console.log(data);
                        }
                    });
                },
                okVal: '确定',
                cancelVal: '关闭',
                cancel: true //为true等价于function(){}
            });
        }

        function addcustomer() {
            document.getElementById("file").click();
        }
        function fileSelected() {
            var formData = new FormData($("#form_file")[0]);
            var filename = $("#file").val();
            console.log("文件名"+filename);
            $("#uploadsuccess").hide();
            if (filename != '') {
                $('#loading').show();
            $.ajax({
                url: '${cdnctx}/system/customerinfo/inputDevice.shtml',
                data: formData,
                type: "post",
                async: true,
                cache: false,
                contentType: false,
                processData: false,
                dataType: "json",
                success: function (data) {
                    if(data){
                        $("#uploadsuccess").show();
                        $('#loading').hide();
                    }else{
                        $('#loading').hide();
                        $('#uploaderror').show();
                    }
                }
            })
        }
        }

    </script>

</head>

<body class="main">
<div class="-frame -style -luster" id="css_container">

    <!--首页框架页眉部分↓-->
    <%@ include file="/WEB-INF/pages/inc/header.jsp" %>
    <!--首页框架页眉部分↑-->

    <div class="content">

        <!-- Left导航菜单◎开始 -->
        <%@ include file="/WEB-INF/pages/inc/leftmenu.jsp" %>
        <!-- Left导航菜单◎结束 -->
        <div class="main-mid">
            <div class="pos"><img src="${cdnctx}/src/index/img/index.png"><a
                    href="<%--${cdnctx}/system/systemMenu.shtml--%>">系统管理
                ></a><a href="${cdnctx}/system/customerinfo/customerMain.shtml">公司信息管理</a></div>
            <div class="css_contentDiv">
                <div class="searchArea" style="padding:10px;">
                    <label class="search_text">集团番号:&nbsp;</label>
                    <select name="groupcode" id="groupcode" class="search_select">
                        <option value="">请选择</option>
                        <c:forEach items="${groupList}" var="entity" varStatus="status">
                            <option value="${entity.groupcode}"
                                    <c:if test="${entity.groupcode==customerInfo.groupcode}">selected</c:if>>${entity.groupname}</option>
                        </c:forEach>
                    </select>
                    <label class="search_text">公司番号:&nbsp;</label>
                    <input type="text" id="companycode" name="companycode" class="search_input">
                    <label class="search_text">公司名称:&nbsp;</label>
                    <input type="text"
                           id="customername" name="customername" class="search_input">
                    <input id="search" type="button" class="search_btn" onclick="search();" value="查&nbsp;询">
                    <input id="add" type="button" class="add_btn" onclick="add();" value="新&nbsp;增"/>
                    <%--<input type="button" class="add_btn" onclick="addcustomer();" style="width:100px" value="导入公司区域"/>&nbsp;&nbsp;&nbsp;--%>
                    <span id="uploadsuccess" style="display:none;font-size: 14px;font-weight: bold">上传成功！</span>
                    <span id="loading" style="display:none;font-size: 14px;font-weight: bold">数据上传中,请稍等...</span>
                    <span id="uploaderror" style="display:none;font-size: 14px;font-weight: bold">上传失败！</span>
                    <form id="form_file" method="post" enctype="multipart/form-data">
                        <input type="file" id="file" name="file" onchange="fileSelected();" style="display: none">
                    </form>
                </div>
                <div id="detailDiv" class="detailDiv">
                    <table id="sjxs" class="list_table">
                        <thead>
                        <tr>
                            <td>所属集团</td>
                            <td>公司番号</td>
                            <td>公司姓名</td>
                            <td>面积</td>
                            <td>人数</td>
                            <td>联系人</td>
                            <td>联系方式</td>
                            <td>类型</td>
                            <td>位置管理</td>
                            <td>区域管理</td>
                            <td>文档操作</td>
                            <td>操&nbsp;&nbsp;&nbsp;作</td>
                        </tr>
                        </thead>
                        <c:if test="${empty(custList) }">
                            <tr class="even" style="color:red">
                                <td colspan="11" class="no-data" style="height: 280px;"></td>
                            </tr>
                        </c:if>
                        <c:if test="${not empty(custList) }">
                            <tbody>
                            <c:forEach items="${custList}" var="entity" varStatus="status">
                                <tr id="${entity.id}">
                                    <td>${entity.groupname}</td>
                                    <td>${entity.companycode}</td>
                                    <td>${entity.customername}</td>
                                    <td>${entity.square}</td>
                                    <td>${entity.employeenum}</td>
                                    <td>${entity.contact}</td>
                                    <td>${entity.mobile}</td>
                                    <td>${entity.customerinfotypename}</td>
                                    <td><a href="javascript:setPosition(${entity.id},'${entity.customername}');">操作</a>
                                    </td>
                                    <td>
                                        <a href="${cdnctx}/systemCustomerArea/customerAreaList.shtml?customerinfoid=${entity.id}">操作</a>
                                    </td>
                                    <td>
                                        <a href="${cdnctx}/documents/documentsInit.shtml?companycode=${entity.companycode}">操作</a>
                                    </td>
                                    <td width="120px;" nowrap="">
                                        <input type="button" class="list_update_btn" onclick="update(${entity.id});"
                                               value="修改">
                                        <input type="button" class="list_delete_btn" onclick="todelete(${entity.id});"
                                               value="删除"></td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </c:if>
                    </table>
                    <br style="clear:both;">
                </div>
                <c:if test="${not empty(custList) }">
                    <div id="pageInfo" class="pageJump">
                        <script type="text/javascript">
                            pagination.getPaginationHtml('JavaScript:jumpPage({0})', ${pageIndex}, ${pageCount}, 'pageInfo');
                        </script>
                        共有${dataCount}条数据
                    </div>
                </c:if>
            </div>
        </div>
    </div>
    <!--首页框架页尾部分↓-->
    <%@ include file="/WEB-INF/pages/inc/footer.jsp" %>
    <!--首页框架页尾部分↑-->
</div>
</body>
</html>